package com.heima.comment.controller;

import com.heima.comment.model.dto.CommentLikeDto;
import com.heima.comment.model.dto.CommentListDto;
import com.heima.comment.model.dto.CommentSaveDto;
import com.heima.comment.service.ApCommentService;
//import com.heima.common.constants.ApCommentConstant;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(path = "/api/v1/comment")
public class ApCommentController {

    @Resource
    private ApCommentService apCommentService;

    /**
     * 发表评论
     *
     * @param dto
     * @return
     */
//    @PostMapping(path = "/save")
//    public ResponseResult save(@RequestBody CommentSaveDto dto) {
//        return apCommentService.save(dto.getArticleId() + "", dto.getContent(), ApCommentConstant.COMMENT_TYPE_ARTICLE);
//    }

    /**
     * 评论点赞
     *
     * @param dto
     * @return
     */
    @PostMapping(path = "/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return apCommentService.like(dto.getCommentId(), dto.getOperation());
    }

    /**
     * 查询评论列表
     *
     * @param dto
     * @return
     */
    @PostMapping(path = "/load")
    public ResponseResult load(@RequestBody CommentListDto dto) {
        return apCommentService.load(dto.getArticleId()+"",dto.getMinDate(),dto.getSize());
    }
}
